﻿using MessagePack;

namespace StudentAgeSaveEditor.GameData.Effect
{
    [Union(0, typeof(EffectorChangeAttr))]
    [Union(1, typeof(EffectorBecomeRelation))]
    [Union(2, typeof(EffectorChangeKnowledge))]
    [Union(3, typeof(EffectorChangeAction))]
    [Union(4, typeof(EffectorChangeRelation))]
    [Union(5, typeof(EffectorChangeItem))]
    [Union(6, typeof(EffectorChangeState))]
    [Union(7, typeof(EffectorChangeCharacter))]
    [Union(8, typeof(EffectorChangeHobby))]
    [Union(9, typeof(EffectorChangeIntent))]
    [Union(11, typeof(EffectorSetEventValue))]
    [Union(12, typeof(EffectorSpecial))]
    [Union(13, typeof(EffectorMoney))]
    [Union(14, typeof(EffectorSocial))]
    [Union(15, typeof(EffectorNpc))]
    [Union(16, typeof(EffectorNpcChange))]
    [Union(17, typeof(EffectorNegotiation))]
    [Union(18, typeof(EffectorWriting))]
    [Union(19, typeof(EffectorDIY))]
    [Union(20, typeof(EffectorShop))]
    [Union(21, typeof(EffectorGaming))]
    [Union(22, typeof(EffectorReading))]
    [Union(23, typeof(EffectorBasketball))]
    [Union(24, typeof(EffectorUI))]
    [Union(25, typeof(EffectorUseful))]
    [Union(26, typeof(EffectSocialMedia))]
    [Union(27, typeof(EffectorParty))]
    public abstract class Effector
    {
        public Effector effector;

        protected List<float> effect;

        private string split = "\n";

        protected List<ulong> incUids;

        public int toRoleId;

        public int fromRoleId;

        public string tag;

        public bool isInc;

        public int evtId;

        public int rateType;

        public Dictionary<string, float> parms;



        public void SetSplit(string _split)
        {
            effector?.SetSplit(_split);
            split = _split;
        }

        public List<ulong> GetBaseIncreaserUids()
        {
            List<ulong> baseIncreaserUids;
            if (effector != null)
            {
                baseIncreaserUids = effector.GetBaseIncreaserUids();
                if (incUids != null)
                {
                    baseIncreaserUids.AddRange(incUids);
                }

                return baseIncreaserUids;
            }

            baseIncreaserUids = new List<ulong>();
            if (incUids != null)
            {
                baseIncreaserUids.AddRange(incUids);
            }

            return baseIncreaserUids;
        }

     

        public void SetParm(string key, float _value)
        {
            if (parms == null)
            {
                parms = new Dictionary<string, float>();
            }

            parms[key] = _value;
            effector?.SetParm(key, _value);
        }

        public float GetParm(string _key)
        {
            if (parms != null && parms.ContainsKey(_key))
            {
                return parms[_key];
            }

            return 0f;
        }

        public void SetTag(string _tag)
        {
            tag = _tag;
            effector?.SetTag(_tag);
        }

        public void SetIsInc(bool _isInc)
        {
            isInc = _isInc;
            effector?.SetIsInc(_isInc);
        }

        public void SetEvtId(int _evtId)
        {
            evtId = _evtId;
            effector?.SetEvtId(_evtId);
        }

        public void SetRateType(int _rateType)
        {
            rateType = _rateType;
            effector?.SetRateType(_rateType);
        }
    }
}
